package cn.iocoder.yudao.module.scenic.remote.client.impl;

import cn.iocoder.yudao.module.scenic.remote.client.ChatClient;
import cn.iocoder.yudao.module.scenic.remote.config.LangchainPropertiesConfig;
import cn.iocoder.yudao.module.scenic.remote.http.RemoteHelper;
import cn.iocoder.yudao.module.scenic.remote.http.RemoteResult;
import cn.iocoder.yudao.module.scenic.remote.model.param.*;
import cn.iocoder.yudao.module.scenic.remote.model.param.common.HeadParam;
import cn.iocoder.yudao.module.scenic.remote.model.param.common.QueryParam;
import cn.iocoder.yudao.module.scenic.remote.model.result.*;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author superzp
 * @date 2024/03/21 17:51
 */
@Component
public class ChatClientImpl  implements ChatClient {

    @Resource
    private LangchainPropertiesConfig langchainPropertiesConfig;


    @Override
    public RemoteResult<ChatWithLLMResult> chatWithLLM(ChatWithLLMBodyParam param) {

        RemoteResult<ChatWithLLMResult> result = RemoteHelper.callPost(
                langchainPropertiesConfig.getHost() + langchainPropertiesConfig.getChatWithLLM(),
                new HeadParam(""),
                new QueryParam(),
                param,
                ChatWithLLMResult.class
        );
        return result;
    }

    @Override
    public RemoteResult<ChatFeedbackResult> chatFeedback(ChatFeedbackBodyParam param) {
        RemoteResult<ChatFeedbackResult> result = RemoteHelper.callPost(
                langchainPropertiesConfig.getHost() + langchainPropertiesConfig.getChatFeedback(),
                new HeadParam(""),
                new QueryParam(),
                param,
                ChatFeedbackResult.class
        );
        return result;
    }

    @Override
    public RemoteResult<ChatWithKnowledgeResult> chatWithKnowledge(ChatWithKnowledgeBodyParam param) {
        RemoteResult<ChatWithKnowledgeResult> result = RemoteHelper.callPost(
                langchainPropertiesConfig.getHost() + langchainPropertiesConfig.getChatWithKnowledge(),
                new HeadParam(""),
                new QueryParam(),
                param,
                ChatWithKnowledgeResult.class
        );
        return result;
    }

    @Override
    public RemoteResult<ChatWithAgentResult> chatWithKnowAgent(ChatWithAgentBodyParam param) {
        RemoteResult<ChatWithAgentResult> result = RemoteHelper.callPost(
                langchainPropertiesConfig.getHost() + langchainPropertiesConfig.getChatWithAgent(),
                new HeadParam(""),
                new QueryParam(),
                param,
                ChatWithAgentResult.class
        );
        return result;
    }

    @Override
    public RemoteResult<ChatWithSearchResult> chatWithSearch(ChatWithSearchBodyParam param) {
        RemoteResult<ChatWithSearchResult> result = RemoteHelper.callPost(
                langchainPropertiesConfig.getHost() + langchainPropertiesConfig.getChatWithSearch(),
                new HeadParam(""),
                new QueryParam(),
                param,
                ChatWithSearchResult.class
        );
        return result;
    }


//    {
//        "query": "恼羞成怒",
//            "conversation_id": "",
//            "history_len": -1,
//            "history": [
//        {
//            "role": "user",
//                "content": "我们来玩成语接龙，我先来，生龙活虎"
//        },
//        {
//            "role": "assistant",
//                "content": "虎头虎脑"
//        }
//  ],
//             "stream": false,
//            "model_name": "chatglm3-6b",
//            "temperature": 0.7,
//            "max_tokens": 0,
//            "prompt_name": "default"
//    }



}
